/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rcnss.ui.menu;

import java.util.StringTokenizer;

import com.rcnss.ui.menu.command.AbstractMenuCommand;

/**
 *
 * @author Baligh GUESMI
 */
public class AdminMenu extends AbstractMenu {
    
	private static final long serialVersionUID = 1L;	
	private String sCommandPackage = "com.rcnss.ui.menu.command.MenuCommand";
	private String[][] menuItem = {
        {"Generale", "Profile", "-", "Logout"},
        {"Adminstration", "Demandes Inscriptions", "-",
                 "Categories", "Structures", "Utilisateurs", "-",
                 "DataBase Server"},
        {"Reclamation", "Nouvelle Reclamation",
                 "List Reclamations", "Reclamations Affecte"},
        {"Aide", "A propos.."}
    };
	
	
    public AdminMenu()
    {
    
    }
    
    public void generateMenu()
    {
        AbstractMenuCommand t = null;
        for(int i=0; i<menuItem.length; i++)
        {
            MenuItem actual = this.addItem(menuItem[i][0], null);
            if(menuItem[i].length != 1)
            {
                for(int j=1; j<menuItem[i].length; j++)
                {
                    if(menuItem[i][j].equals("-"))
                        actual.addSeparator();
                    else
                    {
                    	try {
                                t = (AbstractMenuCommand)Class.forName(sCommandPackage+
                                                removeSpaces(menuItem[i][j])).newInstance();
                                t.setWindow(getWindow());
                        } catch (Exception e) {
                                t = null;
                                e.printStackTrace();
                        }
                        actual.addItem(menuItem[i][j],t);
                    }
                }
            }
        }
    }
    
    public String removeSpaces(String s) {
    	  StringTokenizer st = new StringTokenizer(s," ",false);
    	  String t="";
    	  while (st.hasMoreElements()) t += st.nextElement();
    	  return t;
    }
    
}
